/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.diagram.activity.figure;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;

import com.cea.papyrus.core.figures.NodeFigure;

public class DecisionMergeNodeFigure extends NodeFigure{
	
	/**
	 * The constructor.
	 * 
	 */
	public DecisionMergeNodeFigure () {
		super() ;
		ToolbarLayout layout = new ToolbarLayout();
		setLayoutManager(layout);
		layout.setSpacing(2);
		remove(nameLabel) ;
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.draw2d.Figure#paintBorder(org.eclipse.draw2d.Graphics)
	 */
	@Override
	protected void paintBorder(Graphics graphics) {
		graphics.pushState();
		graphics.setAntialias(SWT.ON);
		Rectangle actionArea = getBounds();
		int height = actionArea.height-1;
		int width = actionArea.width-1;
		int x = getLocation().x;
		int y = getLocation().y;
			
		// Calculate points 
		Point top = new Point(x + width/2, y);
		Point left = new Point(x , y+height/2);
		Point right = new Point(x+width , y+height/2);
		Point bottom = new Point(x+width/2 , y+height);
				
		// Draw action
		graphics.setLineWidth(2) ;
		graphics.setForegroundColor(getBorderColor());
		graphics.drawLine(top, right);
		graphics.drawLine(right, bottom);
		graphics.drawLine(bottom, left);
		graphics.drawLine(left, top);
		graphics.popState();
	}
}
